package exercise.jslide.jslide.model.shapes;

import javafx.scene.canvas.GraphicsContext;
import javafx.geometry.Point2D;

public class Rectangle extends Shape {

    @Override
    protected void drawShape(GraphicsContext gc) {
        gc.fillRect(x, y, width, height);
        gc.strokeRect(x, y, width, height);
    }

    @Override
    public boolean contains(Point2D point) {
        return point.getX() >= x && point.getX() <= x + width &&
                point.getY() >= y && point.getY() <= y + height;
    }

    @Override
    public Shape clone() {
        Rectangle clone = new Rectangle();
        clone.x = this.x;
        clone.y = this.y;
        clone.width = this.width;
        clone.height = this.height;
        clone.fillColor = this.fillColor;
        clone.strokeColor = this.strokeColor;
        clone.strokeWidth = this.strokeWidth;
        return clone;
    }
}